﻿    using System.Collections.Generic;
using nRoute.SiteMaps;
using nRoute.ViewModels;

namespace nRoute.Samples.Netflix.ViewModels
{
    [MapViewModel(typeof(MainPage))]
    public class MainPageViewModel : ViewModelBase 
    {
        public MainPageViewModel() 
        {
            LoadSiteMap();
        }

        public IEnumerable<SiteMapNode> FeatureNodes { get; private set; }

#region Helpers

        private void LoadSiteMap()
        {
            // note SiteMaps are loaded asynchronously 
            SiteMapService.LoadSiteMap((s) =>
            {
                this.FeatureNodes = s.RootNode.ChildNodes;
                NotifyPropertyChanged(() => FeatureNodes);
            });
        }

#endregion

    }
}
